---
title: "Table A.6"
output: 
---

# Table A.6

# Who's to Blame? Postconflict Violence and Public Attitudes Towards Peace Agreements
# Wyer, Frank. 

#clear environment
```{r clear environment}
rm(list = ls())
```

# uncomment and set working directory to replication archive
# setwd("~/blame_replication")

# Uncomment to install packages if necessary
# install.packages("tidyverse")
# install.packages("estimatr")
# install.packages("texreg")


#load packages
```{r}
library(tidyverse)
library(estimatr)
library(texreg)
```

#read in survey data
```{r}
survey_clean <- read.csv("survey_clean.csv")
```

#estimate models with additional controls
```{r extra controls models}
dissident_model_fullc <- lm_lin(formula = dissident_scale ~ treatment, covariates = ~ Q15 + Q25 + urbandummy + engage_zscale + homratediff + homrate100k + factor(regionname) + female + eth_minority + relig_minority + education_level + ses_zscale, se_type = "HC2", data = survey_clean, alpha = .05)

eln_model_fullc <- lm_lin(formula = eln_scale ~ treatment, covariates = ~ Q15 + Q25 + urbandummy + engage_zscale + homratediff + homrate100k + factor(regionname) + female + eth_minority + relig_minority + education_level + ses_zscale, se_type = "HC2", data = survey_clean, alpha = .05)

accords_model_fullc <- lm_lin(formula = accords_scale ~ treatment, covariates = ~ Q15 + Q25 + urbandummy + engage_zscale + homratediff + homrate100k + factor(regionname) + female + eth_minority + relig_minority + education_level + ses_zscale, se_type = "HC2", data = survey_clean, alpha = .05)

index_model_fullc <- lm_lin(formula = outcomes_zscale ~ treatment, covariates = ~ Q15 + Q25 + urbandummy + engage_zscale + homratediff + homrate100k + factor(regionname) + female + eth_minority + relig_minority + education_level + ses_zscale, se_type = "HC2", data = survey_clean, alpha = .05)
```

#estimate models with no controls
```{r no controls models}
dissident_model_noc <- lm_robust(formula = dissident_scale ~ treatment, se_type = "HC2", data = survey_clean, alpha = .05) #without controls, use standard OLS model via lm_robust

eln_model_noc <- lm_robust(formula = eln_scale ~ treatment, se_type = "HC2", data = survey_clean, alpha = .05)

accords_model_noc <- lm_robust(formula = accords_scale ~ treatment, se_type = "HC2", data = survey_clean, alpha = .05)

index_model_noc <- lm_robust(formula = outcomes_zscale ~ treatment, se_type = "HC2", data = survey_clean, alpha = .05)
```

#Generate appendix table
```{r generate table}
texreg(list(accords_model_noc, eln_model_noc, dissident_model_noc, index_model_noc, accords_model_fullc, eln_model_fullc, dissident_model_fullc, index_model_fullc), custom.coef.map = list("(Intercept)" = "(Intercept)", "treatmentT1" = "Postconflict Violence Treatment", "treatmentT2A" = "Government Culpability Treatment", "treatmentT2B" = "Rebel Culpability Treatment"), digits = 2, include.ci = FALSE, single.row = FALSE, include.fstatistic = FALSE, include.rmse = FALSE, include.rsquared = FALSE, include.adjrs = FALSE, include.nobs = TRUE, stars = numeric(0), float.pos = "h", caption.above	= TRUE, caption = "Treatment Effects with Alternative Control Specifications")
```